package ast;

import out.Out;
import mem.interfaces.IMem;
import environnement.interfaces.IEnv;
import exceptions.LogoException;
import ast.interfaces.IAST;
import ast.interfaces.IASTturn;

public class ASTturn implements IASTturn{
	private IAST val;

	public ASTturn(IAST val) {
		this.val = val;
	}

	public IAST getVal() {
		return val;
	}

	public void setVal(IAST val) {
		this.val = val;
	}
	
	public Object eval(Out o,IEnv e,IMem m) throws LogoException{
		Float k = (Float) val.eval(o, e, m);
		m.setA(m.getA() +  k * Math.PI/180);
		return null;
	}
	
	public String toTreeString(String ident,IEnv env,IMem mem){
		return ident + "TURN " + val.toTreeString(ident + "  ",env,mem);
	}
}
